#include "UpperSetNetParamCmd.h"

UpperSetNetParamCmd::UpperSetNetParamCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
    this->m_mode = 0;
}

Package UpperSetNetParamCmd::toPackage()
{
    Package package;
    return package;
}

void UpperSetNetParamCmd::unPackage(Package package)
{
    m_cmdId = package.id();
    QByteArray body;

    body = decrypt(package.body(),KeyType::AES);

    quint16 index = 0;
    quint16 strLength;

    m_mode = body.mid(index,1).toHex().toInt(0,16);
    index += 1;


    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_ip = body.mid(index,strLength);
    index += strLength;

    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_mask = body.mid(index,strLength);
    index += strLength;

    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_gateway = body.mid(index,strLength);
    index += strLength;

}

quint8 UpperSetNetParamCmd::mode() const
{
    return m_mode;
}

void UpperSetNetParamCmd::setMode(const quint8 &mode)
{
    m_mode = mode;
}

QString UpperSetNetParamCmd::ip() const
{
    return m_ip;
}

void UpperSetNetParamCmd::setIp(const QString &ip)
{
    m_ip = ip;
}

QString UpperSetNetParamCmd::mask() const
{
    return m_mask;
}

void UpperSetNetParamCmd::setMask(const QString &mask)
{
    m_mask = mask;
}

QString UpperSetNetParamCmd::gateway() const
{
    return m_gateway;
}

void UpperSetNetParamCmd::setGateway(const QString &gateway)
{
    m_gateway = gateway;
}
